package com.lsh.airticket.service.impl;

import com.github.pagehelper.PageInfo;
import com.lsh.airticket.dao.ModelDao;
import com.lsh.airticket.entity.Model;
import com.lsh.airticket.service.ModelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author lsh
 * @date 2021/2/17
 **/
@Service
public class ModelServiceImpl implements ModelService {

    @Autowired
    ModelDao modelDao;

    @Override
    public PageInfo<Model> findModelList() {

        List<Model> tbModelAll = modelDao.findTbModelAll();
        PageInfo<Model> pageInfo = new PageInfo<>(tbModelAll);

        return pageInfo;
    }

    @Override
    public List<Model> findModelAll() {
        List<Model> tbModelAll = modelDao.findTbModelAll();
        return tbModelAll;
    }

    @Override
    public int insertTbModel(Model model) {
        model.setModelSpaceCreatetime(new Date());
        int i = modelDao.insertTbModel(model);
        return i;
    }

    @Override
    public Model findModelByModelId(Integer ModelId) {

        return modelDao.findTbModelById(ModelId);
    }

    @Override
    public int update(Model model) {
        return modelDao.insertTbModel(model);
    }

    @Override
    public int delete(Integer modelId) {
        return modelDao.deleteTbModelById(modelId);
    }
}
